UisClient Methods

The UisClient object contains the following methods:

Some of the automation calls in this API support multithreading. If supported it is noted below. If multithreading is not noted, the call is single-threaded.

CanSendUISCommand

The CanSendUISCommand checks whether the user has the right security to send a specified UIS command. Include any command components required for the UIS Command to be executed. Also see SendUisCommand for more examples.

Note: This method supports multithreading or the concurrent execution of multiple threads.

Syntax

CanSendUISCommand(ByVal FacilityID As String, ByVal Command As String, ByVal Parameters As String, ByRef strErrorOut) As Boolean

Parameters

Parameter Required Description

FacilityID

Yes

The ID of the facility that has the UIS command.

Command

Yes

The name of the UIS command.

Parameters

Yes

Parameters (command components) that may be required for the UIS command. Use an empty string if none are specified.

Example

The following example will to check if a UISCommand of STATUS is valid and can be sent to UIS or not. Parameters include the Datagroup Ordinal (DGORD parameter) and the Datagroup Type (DGTYPE parameter) which are listed in the UIS definition in the DDS. The method returns True if it succeeded and False if an error occurred.

Copy

CanSendUisCommand

statusStr = uisClient.CanSendUISCommand("WELL_RD_1", "DG_F_DEV", "DGORD=0;DGTYPE=StatusData", errorCode)
 
msgbox statusStr

The following example lists multiple parameters separated by semicolons. The method returns True if it succeeded and False if an error occurred.

Copy

CanSendUISCommand

statusStr1 = uisClient.CanSendUISCommand("WELL_RD_1", "DG_T_DEV", "DGORD=0;DGTYPE=CmdCfgMsg;parmID=523;parmID=524", errorCode)
 
msgbox statusStr1

The following example executes both the CanSendUISCommand and SendUISCommand methods.

Copy

CanSendUISCommand

Sub UISCommandButton1_EventClick()
    Dim This : Set This = UISCommandButton1
 
    Dim GlobalFunctions
        Set GlobalFunctions = CreateObject("CxScript.GlobalFunctions")
        Call GlobalFunctions.EnableLiveMode (True)
 
    Dim uisClient
    Dim statusStr, errorCOde, statusStr1
        Set uisClient = CreateObject("CxUis.UisClient")
        uisClient.Connect("CYGNET.UIS")
        statusStr = uisClient.CanSendUISCommand("WELL_RD_1", "DG_F_DEV", "DGORD=0;DGTYPE=StatusData", errorCode)
        msgbox statusStr

        statusStr1 = uisClient.CanSendUISCommand("WELL_RD_1", "DG_T_DEV", "DGORD=0;DGTYPE=CmdCfgMsg;parmID=523;parmID=524", errorCode)
        msgbox statusStr1
 
    uisClient.SendUISCommand "WELL_RD_1", "DG_F_DEV", "DGORD=0;DGTYPE=StatusData", ""
    uisClient.SendUISCommand "WELL_RD_1", "DG_T_DEV", "DGORD=0;DGTYPE=CmdCfgMsg;parmID=523;parmID=524", ""
End Sub

Back to top

Connect

The Connect method connects the object to a service.

Syntax

Connect(DomainSiteService As String)

Parameters

Parameter Required Description

DomainSiteService

Yes

The [Domain]Site.Service to which to connect. The domain is optional. The service must be a valid one.

Remarks

Returns 0 if successful and a non-zero value if the connection failed.

Example

The following example connects the Client object to the CYGDEMO.<SVC> on domain 5410:

Sub UisConnect()

    'Connect to a UIS
    Dim UisClient
    Set UisClient = CreateObject("CxUis.UisClient")
    UisClient.Connect("[5410]CYGDEMO.UIS")

End Sub

Back to top

CreateDataArray

The CreateDataArray method creates a data array for sending and receiving data (via GetAndSendData).

Syntax

CreateDataArray(Items As Variant, DataInfoArray As Variant) As Boolean

Parameters

Parameter Required Description

Items

Yes

The number of rows in the array.

DataInfoArray

Yes

Input/Output. The array that is created.

Remarks

CreateDataArray creates a two-dimensional array whose rows can be filled with the UpdateDataArrayRow method. These methods are used for sending multiple data group element or UDC values to a device. One row represents one data group element or UDC.

Example

See the GetAndSendData method for an example.

Back to top

DeleteQueueEntry

The DeleteQueueEntry method deletes a queue entry from a pending UIS queue.

Note: This method supports multithreading or the concurrent execution of multiple threads.

Syntax

DeleteQueueEntry(QueueName As String, UisSessionToken As String, QueueEntryId As String, ErrorOut) As Boolean

Parameters

Parameter Required Description

QueueName

Yes

The name of the UIS queue.

UisSessionToken

Yes

 

QueueEntryId

Yes

 

ErrorOut

Yes

Output. The returned error string or empty string on success.

Back to top

Disconnect

The Disconnect method disconnects from the connected service.

Syntax

Disconnect() As Integer

Remarks

The Disconnect method returns 0 if successful and a non-zero value if the disconnect failed.

Example

The following example disconnects the Client object from the connected service, and pops a message box if it is unsuccessful:

Copy
Disconnect
Sub Svc.Disconnect()
 
    <SvcClient>.Disconnect()
    MsgBox "Service has disconnected."
    
    If <SvcClient>.Disconnect <> 0 
    Then
        MsgBox "Failed to disconnect."
    End If

End Sub

Back to top

GetAndSendData

The GetAndSendData method sends data to and gets data from a device.

Syntax

GetAndSendData(DataInfoArray As Variant, Items As Variant, OutError As String, [ShowWaitDlg As Variant], [FromDeviceParams As String], [ToDeviceParams As String]) As Boolean

Parameters

Parameter Required Description

DataInfoArray

Yes

Input/Output. The data array.

Items

Yes

The number of rows from the array to send.

OutError

Yes

Stores an error message if an error occurs.

ShowWaitDlg

Yes

Indicates whether to show a status dialog box when the method is being executed (True) or not (False).

FromDeviceParams

Yes

Parameters that may be required when getting from the device. Usually an empty string is passed.

ToDeviceParams

Yes

Parameters that may be required when sending to the device. Usually an empty string is passed.

Remarks

This method sends multiple data group element or UDC values, each represented by a single row in DataInfoArray. The array is created using CreateDataArray and filled using UpdateDataArrayRow (see method specifications above).

Example

The following method creates a data array with three rows to be sent to the OpCode data group. Each row represents a data group element, with a value being generated based on the row number (for testing). The row values are viewed using the ParseDataArrayRow method, then the data is sent to the RTU1 device.

Copy
GetAndSendData
Sub OpCodeUpdateTest ()
    Dim uisClient, arrData, i, strError, nRows
    Dim strDEID, strDesc, strSendVal, strRecVal
    Dim strFacility, strDatagroup, iOrdinal, strUDC 
    
    Set uisClient = CreateObject("CxUis.UisClient")
    uisClient.Connect("CYGDEMO.UIS")
    uisClient.CreateDataArray 3, arrData
    nRows = 3 
    
    'Update each row in the data array
    For i = 0 To nRows - 1
        strDEID = "TableVal0" & CStr(i + 1)
        strDesc = "Table Value # " & CStr(i + 1)
        strSendVal = CStr(i * 10)
        strRecVal = CStr(i * -10) 
        
        uisClient.UpdateDataArrayRow arrData, i, "RTU1", "OpCodes",1, strDEID, "", strDesc, strRecVal, strSendVal,True, True, strError
    Next  
    
    'Check the row values
    For i = 0 To nRows - 1
        uisClient.ParseDataArrayRow arrData,i, strFacility, strDatagroup,iOrdinal, strDEID, strUDC, strDesc, strRecVal,strSendVal, True, True, strError
        MsgBox "Data Row " & CSTR(i) & " " & strFacility & ", " &strDatagroup & ", " & CSTR(iOrdinal) & ", " & strDEID & ", " & strUdc & ", " & strDesc & ", " & strRecVal & ", " & strSendVal
    Next 
    
    'Send the data
    uisClient.GetAndSendData arrData, nRows, strError, False, "", ""
End Sub

Back to top

GetAssociatedDdsName

The GetAssociatedDdsName method gets the Device Definition Service name associated with the current UIS.

Note: This method supports multithreading or the concurrent execution of multiple threads.

Syntax

GetAssociatedDdsName() As String

Remarks

Returns the DDS name in "site.service" format. Each UIS has exactly one associated DDS. The CxDds library has a similar method, GetAssociatedUisName(), for getting a DDS name based on a UIS. If an error occurs, such as in connecting to the service, the error description will be returned.

Example

The following function returns a DDS name based on a UIS name.

Copy

GetAssociatedDdsName

Function GetDDSName (uisName)
    'Create and initialize the UIS Client
    Dim uisClient
    Set uisClient = CreateObject("CxUis.UisClient")
    uisClient.Connect("CYGDEMO.UIS")
 
    'Return the DDS name
    GetDDSName = uisClient.GetAssociatedDdsName()
End Function

Back to top

GetCommDevProperty

This method is obsolete. Use DdsClient.GetCommDevProperty instead.

Back to top

GetConsoleData

The GetConsoleData method returns the console text and display attributes as two 25x80 arrays of unsigned characters.

Syntax

GetConsoleData(ByRef pText, ByRef pAttr) As Integer

Parameters

Parameter Required Description

pText

Yes

A two-dimensional 25x80 array of console text attributes returned by this method.

pAttr

Yes

A two-dimensional 25x80 array of console display attributes returned by this method.

Remarks

This method returns 0 if successful.

Example

The following example writes the console text and display attributes to a CSV file.

Copy
GetConsoleData
Sub
    Dim aryText, aryAttr, nRet
    nRet = <NameofServiceClientObject>.GetConsoleData(aryText, aryAttr)
 
    ' Write text attributes to CSV file
    Dim i, j, strMsg
        For i = 0 To UBound(aryText, 1)
        For j = 0 To UBound(aryText, 2)
            strMsg = strMsg + CStr(aryText(i, j)) + ","
        Next
            strMsg = strMsg + vbCr
    Next
 
    dim fso, file
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set file = fso.OpenTextFile("c:\console_text_attrs.csv", 2, True)
    file.WriteLine(strMsg)
    file.Close 
 
    strMsg = ""
 
    ' Write display attributes to CSV file
        For i = 0 To UBound(aryAttr, 1)
        For j = 0 To UBound(aryAttr, 2)
            strMsg = strMsg + CStr(aryAttr(i, j)) + ","
        Next
            strMsg = strMsg + vbCr
    Next
 
    Set file = fso.OpenTextFile("c:\console_disp_attrs.csv", 2, True)
    file.WriteLine(strMsg)
    file.Close 
 
    MsgBox nRet
End Sub

Back to top

GetDataGroupFromDeviceByKey

The GetDataGroupFromDeviceByKey method gets a data group from the device by database key (DbKey).

Note: This method supports multithreading or the concurrent execution of multiple threads.

Syntax

GetDataGroupFromDeviceByKey(DataGroupKey As String, ShowWaitDlg As Boolean, FromDeviceParams As String, ToDeviceParams As String, OutError As String) As Boolean

Parameters

Parameter Required Description

DataGroupKey

Yes

The database key (DbKey) for the data group.

ShowWaitDlg

Yes

Indicates whether to show a status dialog box when the method is being executed (True) or not (False).

FromDeviceParams

Yes

Parameters that may be required when getting from the device. Usually an empty string is passed.

ToDeviceParams

Yes

Parameters that may be required when sending to the device. Usually an empty string is passed.

OutError

Yes

Stores an error message if an error occurs.

Back to top

GetDataGroupFromDeviceByKeyWithTxData

The GetDataGroupFromDeviceByKeyWithTxData method gets a data group from the device with transaction data.

Note: This method supports multithreading or the concurrent execution of multiple threads.

Syntax

GetDataGroupFromDeviceByKeyWithTxData(DataGroupKey As String, ShowWaitDlg As Boolean, MaxWaitTimeInMS As Integer, FromDeviceParams As String, OutDataGroupTxHdr, OutDataGroupTxData, OutError) As Boolean

Parameters

Parameter Required Description

DataGroupKey

Yes

The database key (DbKey) for the data group.

ShowWaitDlg

Yes

Indicates whether to show a status dialog box when the method is being executed (True) or not (False).

MaxWaitTimeInMS

Yes  

FromDeviceParams

Yes

Parameters that may be required when getting from the device. Usually an empty string is passed.

OutDataGroupTxHdr

Yes  

OutDataGroupTxData

Yes  

OutError

Yes

Stores an error message if an error occurs.

Back to top

GetReferences

Note: This method supports multithreading or the concurrent execution of multiple threads.

The GetReferences method refreshes the list of services referenced by the connected service.

Syntax

GetReferences() As Integer

Return Values

This method returns all references for the connected service.

Example

The following example refreshes the connected services:

Copy
GetReferences
Sub GetReferences()
 
    <NameofServiceClientObject>.GetReferences
    MsgBox "Services references retrieved"

End Sub

The following example refreshes the referenced services.

Copy

GetReferences

Sub GetReferences()
    'Create and initialize the UIS Client
    Dim uisClient
    Set uisClient = CreateObject("CxUis.UisClient")
    uisClient.Connect("CYGDEMO.UIS")
 
    uisClient.GetReferences()
End Sub

Back to top

ParseDataArrayRow

The ParseDataArrayRow method parses a row in the data array, returning individual values.

Syntax

ParseDataArrayRow(DataInfoArray As Variant, Row As String, Facility As String, DataGroup As String, Ordinal As String, Deid As String, Udc As String, Prompt As String, RecValue As String, SendValue As String, GetFromDevice As Boolean, SendToDevice As Boolean, errorstring As String) As Boolean

Parameters

Parameter Required Description

DataInfoArray

Yes

Input/Output. The array of data to be parsed.

Row

Yes

The index of the row to be parsed (zero-based).

Facility

Yes

Output. The facility ID.

DataGroup

Yes

Output. The data group type.

Ordinal

Yes

Output. The data group ordinal.

Deid

Yes

Output. The data group element ID (DEID) to set.

Udc

Yes

Output. The UDC to set.

Prompt

Yes

The prompt text in the dialog box.

RecValue

Yes

The value of the field that is received.

SendValue

Yes

Output. The value of the field to set.

GetFromDevice

Yes

Whether to get data from the device (True) or not (False).

SendToDevice

Yes

Whether to send data to the device (True) or not (False).

ErrorString

Yes

Stores an error message if an error occurs.

Remarks

This method parses a row in a two-dimensional array, usually after the array has been filled using UpdateDataArrayRow. The values of the row are saved to the variables passed for each field.

Example

See the GetAndSendData method for an example.

Back to top

PerformCmd

The PerformCmd method executes a UIS Command Task.

Note: This method supports multithreading or the concurrent execution of multiple threads.

Syntax

PerformCmd (Request As Variant, Response As Variant) As Integer

Parameters

Parameter Required Description

Request

Yes

An array of parameters describing the Command Task to execute. Request parameters include:

(Count as Short, CmdDescriptor (CmdType as String, CmdParameters as String, RequestingId as Integer, StatusPointId as Integer, DdsKey as Integer, CmdPriority as Integer, RequestType as String, CmdOperator as String, CmdDescriptor (DeviceParameter as String, SelectionTag as String, Comparison as String, ComparisonValue as String, SelectionTagType as String) as Array) as Array) as Array

Response

Yes

An array including the number of times the Command Task has been executed and any errors encountered during the last run. Response parameters include:

(Count as Integer, Error as Integer) as Array

Remarks

PerformCmd (Request (Count as Short, CmdDescriptor (CmdType as String, CmdParameters as String, RequestingId as Integer, StatusPointId as Integer, DdsKey as Integer, CmdPriority as Integer, RequestType as String, CmdOperator as String, CmdDescriptor (DeviceParameter as String, SelectionTag as String, Comparison as String, ComparisonValue as String, SelectionTagType as String) as Array) as Array) as Array), Response (Count as Integer, Error as Integer) as Array)

The command priority for a scripted UIS command can be assigned; by setting the UisCmdPriority=<priority> parameter where <priority> is one of the following 'Low', 'Medium', 'High', 'User', or 'Admin'.

See Prioritizing Messages in the Communication Queue for more information.

Back to top

RetrieveDeviceSummaryStatistics

The RetrieveDeviceSummaryStatistics method retrieves current status and summary statistics for a device in the UIS as XML.

Note: This method supports multithreading or the concurrent execution of multiple threads.

Syntax

RetrieveDeviceSummaryStatistics(DeviceID As String) As String

Parameters

Parameter Required Description

DeviceID

Yes

The ID of the device to retrieve.

Back to top

RetrieveMultipleDeviceSummaryStatistics

The RetrieveMultipleDeviceSummaryStatistics method retrieves current status and summary statistics for multiple devices in the UIS as XML.

Note: This method supports multithreading or the concurrent execution of multiple threads.

Syntax

RetrieveMultipleDeviceSummaryStatistics(DeviceIdArray) As String

Parameters

Parameter Required Description

DeviceIdArray

Yes

An array of IDs of devices to retrieve.

Back to top

RetrieveMultiQueueSnapshotXML

The RetrieveMultiQueueSnapshotXML method retrieves multiple queue snapshots as XML.

Note: This method supports multithreading or the concurrent execution of multiple threads.

Syntax

RetrieveMultiQueueSnapshotXML(QueueNameArray) As String

Parameters

Parameter Required Description

QueueNameArray

Yes

An array of queue names to retrieve.

Back to top

RetrieveQueueSnapshotXML

The RetrieveQueueSnapshotXML method retrieves queue snapshot as XML.

Note: This method supports multithreading or the concurrent execution of multiple threads.

Syntax

RetrieveQueueSnapshotXML(QueueName As String) As String

Parameters

Parameter Required Description

QueueName

Yes

The name or the queue to retrieve.

Back to top

SendDataGroupToDeviceByKey

The SendDataGroupToDeviceByKey method sends a data group transaction to the device by database key (DbKey).

Note: This method supports multithreading or the concurrent execution of multiple threads.

Syntax

SendDataGroupToDeviceByKey(DataGroupKey As String, ShowWaitDlg As Boolean, MaxWaitTimeInMS As Integer, FromDeviceParams As String, ToDeviceParams As String, DataGroupTxData As String, OutDataGroupTxHdr, OutError) As Boolean

Parameters

Parameter Required Description

DataGroupKey

Yes

The database key (DbKey) for the data group.

ShowWaitDlg

Yes

Indicates whether to show a status dialog box when the method is being executed (True) or not (False).

MaxWaitTimeInMS

Yes

 

FromDeviceParams

Yes

Parameters that may be required when getting from the device. Usually an empty string is passed.

ToDeviceParams

Yes

Parameters that may be required when sending to the device. Usually an empty string is passed.

DataGroupTxData

Yes

 

OutDataGroupTxHdr

Yes

 

OutError

Yes

Stores an error message if an error occurs.

Back to top

SendSingleDEId

The SendSingleDEId method sends a single data group element value to a device without user interaction. It first requests the group from the device, and then sends the group with the one changed value back to the device.

Note: This method supports multithreading or the concurrent execution of multiple threads.

Syntax

SendSingleDEId(FacilityID As String, DataGroup As String, Ordinal As Integer, Deid As String, Value As String, ShowWaitDlg As Boolean, FromDeviceParams As String, ToDeviceParams As String, OutError As String) As Boolean

Parameters

Parameter Required Description

FacilityID

Yes

The facility ID.

DataGroup

Yes

The data group type.

Ordinal

Yes

The data group ordinal.

Deid

Yes

The data group element ID (DEID) to be set.

Value

Yes

The value of the data group element ID.

ShowWaitDlg

Yes

Indicates whether to show a status dialog box when the method is being executed (True) or not (False).

FromDeviceParams

Yes

Parameters that may be required when getting from the device. Usually an empty string is passed.

ToDeviceParams

Yes

Parameters that may be required when sending to the device. Usually an empty string is passed.

OutError

Yes

Stores an error message if an error occurs.

Remarks

When the device parameter fields are used, both FromDeviceParams and ToDeviceParams are typically the same. The method returns True if it succeeded and False if an error occurred.

Example

The following method sets the C02 field of the GasAnal data group to a given value. During the call a wait dialog box is shown (ShowWaitDlg). If an error occurred in processing, it is displayed in a message box.

Copy

SendSingleDEId

Sub SetC02 (val)
    Dim uisClient, strError, result
    Set uisClient = CreateObject("CxUis.UisClient")
    uisClient.Connect("CYGDEMO.UIS")
 
    'Set the DEID
    result = uisClient.SendSingleDEId("RTU1", "GasAnal", 1, "C02", val, True, "", "", strError)
 
    If (Not result) Then
        MsgBox "An error occurred: " & strError
    End If
End Sub

Back to top

SendSingleDEIdByKey

The SendSingleDEIdByKey method sends a single data group element ID by a data group’s DB key to a device.

Note: This method supports multithreading or the concurrent execution of multiple threads.

Syntax

SendSingleDEIdByKey(DataGroupKey As String, Deid As String, Value As String, ShowWaitDlg As Boolean, FromDeviceParams As String, ToDeviceParams As String, OutError As String) As Boolean

Parameters

Parameter Required Description

DataGroupKey

Yes

The database key (DbKey) for the data group.

Deid

Yes

The data group element ID (DEID) to be set.

Value

Yes

The value of the data group element ID.

ShowWaitDlg

Yes

Indicates whether to show a status dialog box when the method is being executed (True) or not (False).

FromDeviceParams

Yes

Parameters that may be required when getting from the device. Usually an empty string is passed.

ToDeviceParams

Yes

Parameters that may be required when sending to the device. Usually an empty string is passed.

OutError

Yes

Stores an error message if an error occurs.

Remarks

This method can be used with other methods such as DdsClient.GetDataGroupInfo or DdsClient.GetDataGroupProperty that return a database key (DbKey). When the device parameter fields are used, both FromDeviceParams and ToDeviceParams are typically the same. The method returns True if it succeeded and False if an error occurred.

Example

The following function serves as a wrapper for the SendSingleDEIdByKey method. It accepts a database key (DbKey), data group element ID, and value, and performs the operation with the other fields fixed.

Copy

SendSingleDEIdByKey

Function SetField (dbKey, deid, val)
    Dim uisClient, strError
    Set uisClient = CreateObject("CxUis.UisClient")
    uisClient.Connect("CYGDEMO.UIS")
 
    'Return the success of the function
    SetField = uisClient.SendSingleDEIdByKey (dbKey, deid, val, False, "","", strError)
End Function

Back to top

SendSingleDEIdInteractive

The SendSingleDEIdInteractive method sends a single data group element ID to a device with user interaction.

Note: This method supports multithreading or the concurrent execution of multiple threads.

Syntax

SendSingleDEIdInteractive(FacilityID As String, DataGroup As String, Ordinal As Integer, Deid As String, Prompt As String, Title As String, FromDeviceParams As String, ToDeviceParams As String, Value As String, OutError As String) As Boolean

Parameters

Parameter Required Description

FacilityID

Yes

The facility ID.

DataGroup

Yes

The data group type.

Ordinal

Yes

The data group ordinal.

Deid

Yes

The data group element ID (DEID) to be set.

Prompt

Yes

The prompt text in the dialog box.

Title

Yes

The title of the dialog box.

FromDeviceParams

Yes

Parameters that may be required when getting from the device. Usually an empty string is passed.

ToDeviceParams

Yes

Parameters that may be required when sending to the device. Usually an empty string is passed.

Value

Yes

Input/Output. The value of the data group element ID.

OutError

Yes

Stores an error message if an error occurs.

Remarks

When Value is passed as a non-empty string, this will be the default value placed in the prompt. This field also holds the returned value that was sent to the device. When the device parameter fields are used, both FromDeviceParams and ToDeviceParams are typically the same. The method returns True if it succeeded and False if an error occurred.

Example

The following method displays a prompt to set a given field in the OpCodes data group. If an error occurs, the error message is displayed. Otherwise, the value sent to the device is displayed.

Copy

SendSingleDEIdInteractive

Sub SetOpCodePrompt (field)
    Dim uisClient, strVal, strError, result
    Set uisClient = CreateObject("CxUis.UisClient")
    uisClient.Connect("CYGDEMO.UIS")
 
    'Display the DEID prompt
    result = uisClient.SendSingleDEIdInteractive("RTU1", "OpCodes", 1,field, "Enter a new value: ", "Op code","", "", strVal, strError)
 
    If (result) Then
        MsgBox field & " set to " & strVal
    Else
        MsgBox "An error occurred: " & strError
    End If
End Sub

Back to top

SendSingleUdc

The SendSingleUdc method sends a single Uniform Data Code (UDC) to a device without user interaction.

Note: This method supports multithreading or the concurrent execution of multiple threads.

Syntax

SendSingleUdc(FacilityID As String, DataGroup As String, Ordinal As Integer, Udc As String, Value As String, ShowWaitDlg As Boolean, FromDeviceParams As String, ToDeviceParams As String, OutError As String) As Boolean

Parameters

Parameter Required Description

FacilityID

Yes

The facility ID.

DataGroup

Yes

The data group type.

Ordinal

Yes

The data group ordinal.

Udc

Yes

The UDC to set.

Value

Yes

The value of the UDC.

ShowWaitDlg

Yes

Indicates whether to show a status dialog box when the method is being executed (True) or not (False).

FromDeviceParams

Yes

Parameters that may be required when getting from the device. Usually an empty string is passed.

ToDeviceParams

Yes

Parameters that may be required when sending to the device. Usually an empty string is passed.

OutError

Yes

Stores an error message if an error occurs.

Remarks

When the device parameter fields are used, both FromDeviceParams and ToDeviceParams are typically the same. The method returns True if it succeeded and False if an error occurred.

Note: If the Facility ID linked to the data group and the UDC point mapped to the concerned data element in the same data group are different, then the Facility Id passed to the SendSingleUdc method should not be selected from device or datagroup attributes, but should be hard-coded to reflect the Facility ID of the UDC point.

Example

The following method sets the RPM UDC field of the ProdConfig data group to a given value. During the call a wait dialog box is shown (ShowWaitDlg). If an error occurred in processing, it is displayed in a message box.

Copy

SendSingleUdc

Sub SetRPM (val)
    Dim uisClient, strError, result
    Set uisClient = CreateObject("CxUis.UisClient")
    uisClient.Connect("CYGDEMO.UIS")
 
    'Set the UDC
    result = uisClient.SendSingleUdc("RTU1", "ProdConfig", 1, "RPM", val, True,"", "", strError)
 
    If (Not result) Then
        MsgBox "An error occurred: " & strError
    End If
End Sub

Back to top

SendSingleUdcByKey

The SendSingleUdcByKey method sends a single Uniform Data Code (UDC) by database key (DbKey) to a device without user interaction.

Note: This method supports multithreading or the concurrent execution of multiple threads.

Syntax

SendSingleUdcByKey(DataGroupKey As String, Udc As String, Value As String, ShowWaitDlg As Boolean, FromDeviceParams As String, ToDeviceParams As String, OutError As String) As Boolean

Parameters

Parameter Required Description

DataGroupKey

Yes

The database key (DbKey) ) for the data group.

Udc

Yes

The UDC to set.

Value

Yes

The value of the UDC.

ShowWaitDlg

Yes

Indicates whether to show a status dialog box when the method is being executed (True) or not (False).

FromDeviceParams

Yes

Parameters that may be required when getting from the device. Usually an empty string is passed.

ToDeviceParams

Yes

Parameters that may be required when sending to the device. Usually an empty string is passed.

OutError

Yes

Stores an error message if an error occurs.

Remarks

This method can be used with other methods such as DdsClient.GetDataGroupInfo or DdsClient.GetDataGroupProperty that return a database key (DbKey). When the device parameter fields are used, both FromDeviceParams and ToDeviceParams are typically the same. The method returns True if it succeeded and False if an error occurred.

Example

The following function serves as a wrapper for the SendSingleUdcByKey method. It accepts a database key (DbKey), UDC, and value, and performs the operation with the other fields fixed.

Copy

SendSingleUdcByKey

Function SetField (dbKey, udc, val)
    Dim uisClient, strError
    Set uisClient = CreateObject("CxUis.UisClient")
    uisClient.Connect("CYGDEMO.UIS")
 
    'Return the success of the function
    SetField = uisClient.SendSingleUdcByKey (dbKey, udc, val, False, "", "", strError)
End Function

Back to top

SendSingleUdcInteractive

The SendSingleUdcInteractive method sends a single UDC to a device with user interaction.

Note: This method supports multithreading or the concurrent execution of multiple threads.

Syntax

SendSingleUdcInteractive(FacilityID As String, DataGroup As String, Ordinal As Integer, Udc As String, Prompt As String, Title As String, FromDeviceParams As String, ToDeviceParams As String, Value As String, OutError As String) As Boolean

Parameters

Parameter Required Description

FacilityID

Yes

The facility ID.

DataGroup

Yes

The data group type.

Ordinal

Yes

The data group ordinal.

Udc

Yes

The UDC to set.

Prompt

Yes

The prompt text in the dialog box.

Title

Yes

The title of the dialog box.

FromDeviceParams

Yes

Parameters that may be required when getting from the device. Usually an empty string is passed.

ToDeviceParams

Yes

Parameters that may be required when sending to the device. Usually an empty string is passed.

Value

Yes

Input/Output. The value of the UDC.

OutError

Yes

Stores an error message if an error occurs.

Remarks

When Value is passed as a non-empty string, this will be the default value placed in the prompt. This field also holds the returned value that was sent to the device. When the device parameter fields are used, both FromDeviceParams and ToDeviceParams are typically the same. The method returns True if it succeeded and False if an error occurred.

Example

The following method displays a prompt to set the value of the VLVCTLPO UDC in the PumpData data group. If an error occurs, the error message is displayed. Otherwise, the value sent to the device is displayed.

Copy

SendSingleUdcInteractive

Sub ValvePositionPrompt ()
    Dim uisClient, strVal, strError, result
    Set uisClient = CreateObject("CxUis.UisClient")
    uisClient.Connect("CYGDEMO.UIS")
 
    'Display the DEID prompt
    result = uisClient.SendSingleUdcInteractive("RTU1", "PumpData", 1,_
    "VLVCTLPO", "Enter a position (0-100): ", "Valve Position", "", "", strVal, strError)
 
    If (result) Then
        MsgBox "Valve set to " & strVal & "%."
    Else
        MsgBox "An error occurred: " & strError
    End If
End Sub

Back to top

SendUISCommand

The SendUISCommand method sends a command to a UIS for a specified facility. Also see CanSendUisCommand and CxScript.GlobalFunctions.SendUisCommand.

Note: This method supports multithreading or the concurrent execution of multiple threads.

Syntax

SendUISCommand(FacilityId As String, Command As String, [Parameters As String], [StatusPointID As String])

Parameters

Parameter Required Description

FacilityId

Yes

The ID of the facility that has the UIS command.

Command

Yes

The name of the command.

Parameters

Yes

Parameters that may be required for the UIS command. Use an empty string if none are specified.

Note: The maximum length of the command parameter string for a Send UIS Command message is 1200 characters. CygNet Software will report if a UIS Command message exceeds the maximum parameter length of 1200 characters.

StatusPointID

Yes

The tag string of an optional status point for the command (in progress, completed, success, etc.). Use an empty string if none specified.

Remarks

This method sends a command on the UIS to which the UisClient is connected. The optional parameters are sent in semicolon delimited format ("param=value"). The status point, if used, is updated automatically. In CygNet Studio, the UIS Command Button can also be used.

The command priority for a scripted UIS command can be assigned; by setting the UisCmdPriority=<priority> parameter where <priority> is one of the following 'Low', 'Medium', 'High', 'User', or 'Admin'.

See Prioritizing Messages in the Communication Queue for more information.

Example — Get status

The following method updates the status of the METER206 device.

Copy

SendUISCommand — Get Status

Sub GetStatus ()
    'Create and initialize the UIS Client
    Dim uisClient
    Set uisClient = CreateObject("CxUis.UisClient")
    uisClient.Connect("CYGDEMO.UIS")
 
    'Get status (no parameters or status point)
    uisClient.SendUISCommand "METER206", "STATUS", "", ""
End Sub

Example — Set UIS Command Priority

The following method sets the UIS command priority.

Copy

SendUISCommand — Set UIS Command Priority

Dim objUisClient : Set objUisClient = CreateObject("CxUis.UisClient")
Dim strUis, strRemoteDevice, strDataGroup, arrCmdPriority, strCmdPriority
 
strUis = "CYGDEMO.UIS"
strRemoteDevice = "FB107"
strDataGroup = "RtuConfig"
arrCmdPriority = Array("", "Low", "Medium", "High", "User", "Admin")
 
objUisClient.Connect strUis
 
'DG_F_DEV direct to data group
    For Each strCmdPriority In arrCmdPriority
    objUisClient.SendUISCommand strRemoteDevice, "DG_F_DEV", "DGORD=1;DGTYPE=" & strDataGroup & ";UisCmdPriority=" & strCmdPriority & ";", ""
Next
 
'preconfigured UIS command on device
    For Each strCmdPriority In arrCmdPriority
objUisClient.SendUISCommand strRemoteDevice, "GETTIME", "UisCmdPriority=" & strCmdPriority & ";", ""
Next

Example — Using DG_F_DEV or DG_T_DEV component types

The following examples show how to send a UIS Command that is not predefined on a device. This example allows you to specify the DG_F_DEV or DG_T_DEV component type, then the data group ordinal (DGORD) and data group type (DGTYPE) that you want to poll.

The same functionality is available with the CxScript.GlobalFunctions method SendUisCommand.

Copy

SendUISCommand — DG_T_DEV

Dim uisClient
Set uisClient = CreateObject("CxUis.UisClient")
uisClient.Connect("CYGDEMO.UIS")
uisClient.SendUISCommand "WELLPILOT_KS_WELL00", "DG_T_DEV", "DGORD=0;DGTYPE=ProVlvOpCl;OpenClose=1", ""

 

Copy

SendUISCommand — DG_F_DEV

Dim uisClient
Set uisClient = CreateObject("CxUis.UisClient")
uisClient.Connect("CYGDEMO.UIS")
uisClient.SendUISCommand "WELLPILOT_KS_WELL00", "DG_F_DEV", "DGORD=0;DGTYPE=BasicPoll", ""

where

Script Element Corresponds to More information

UisClient.SendUisCommand

Send UIS Command  

CYGDEMO.UIS

CygNet Site.Service  

WELLPILOT_KS_WELL00

Facility  

DG_T_DEV (to send a data group to a field device)

DG_F_DEV (to get a data group from a field device)

Component type

UISComponentType

DGORD

Ordinal of the data group (for example, 0)

Data Group Ordinals

DGTYPE

Data group type (for example, ProVlvOpCl – is the Production Valve Open and Close data group)

 

OpenClose

Parameters to send to the device (for example, Open = 1 and Close = 0) UIS Command Components

Note: You can find the Component Type, Data Group Ordinal, and Data Group Type in the properties of the Data Group. All of the information above is available in the UIS Command Properties, if you have a UIS command created already but want to use a script to run the command.

Back to top

SetActiveCommLine

The SetActiveCommLine method sets the active communication line for a remote device.

Note: This method supports multithreading or the concurrent execution of multiple threads.

Syntax

SetActiveCommLine(RemoteDevice As String, ActiveCommLine As Variant)

Parameters

Parameter Required Description

RemoteDevice

Yes

The remote device ID.

ActiveCommLine

Yes

The ID of the communication line to use. 1 is Primary, 2 is Secondary.

Example

The following method sets the Active Communication Line of a specific device to Secondary.

Copy

SetActiveCommLine

Sub SetCommSecondary()
 
    'Create and initialize the UIS Client
    Dim uisClient
    Set uisClient = CreateObject("CxUis.UisClient")
    uisClient.Connect("CYGDEMO.UIS")
 
    'Get Device ID
    Dim strDeviceId
    strDeviceId = edtDeviceID.Text
 
    'Set active comm line to secondary
    Dim bSuccess
    bSuccess = ddsClient.SetActiveCommLine (strDeviceId, 2)
    If bSuccess = False Then
        MsgBox "Error in setting active comm line."
    Else
        MsgBox "Comm Line successfully set."
    End If
End Sub

SetCommDevProperty

This method is obsolete. Use DdsClient.SetCommDevProperty.

Back to top

UpdateDataArrayRow

The UpdateDataArrayRow method updates a row in the data array.

Syntax

UpdateDataArrayRow(DataInfoArray As Variant, Row As Integer, Facility As String, DataGroup As String, Ordinal As String, Deid As String, Udc As String, Desc As String, RecValue As String, SendValue As String, GetFromDevice As Boolean, SendToDevice As Boolean, OutError As String) As Boolean

Parameters

Parameter Required Description

DataInfoArray

Yes

Input/Output. The array of data to be updated.

Row

Yes

The index of the row to be updated (zero-based).

Facility

Yes

The facility ID.

DataGroup

Yes

The data group type.

Ordinal

Yes

The data group ordinal.

Deid

Yes

The data group element ID (DEID) to be set. (See Remarks).

Udc

Yes

The UDC to set (see Remarks).

Desc

Yes

The description of the data group element ID or UDC.

RecValue

Yes

The value of the field that is received.

SendValue

Yes

The value of the field to set.

GetFromDevice

Yes

Whether to get data from the device (True) or not (False).

SendToDevice

Yes

Whether to send data to the device (True) or not (False).

OutError

Yes

Stores an error message if an error occurs.

Remarks

This method updates a row in a two-dimentional array that has been previously created using CreateDataArray. Each row can use either the Deid or Udc field. The field that is not being used can be left as an empty string.

Example

See the GetAndSendData method for an example.

Back to top